package com.dididoctor.patient.Activity.Service;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dididoctor.patient.Activity.Service.ServiceDetail.ServiceDetailActivity;
import com.dididoctor.patient.MV.adapter.CommonAdapter;
import com.dididoctor.patient.MV.adapter.ViewHolder;
import com.dididoctor.patient.R;
import com.dididoctor.patient.Utils.LoaderImage;
import com.dididoctor.patient.Utils.UserHeadImage;

import java.util.List;

/**
 * Created by Administrator on 2016/4/15.
 */
public class ServiceAdapter extends CommonAdapter<ServiceBean> {

    private ImageView headImage;
    private TextView mTvName, mTvDescription, mTvPrize;
    private Context context;
    private LoaderImage loaderImage;

    public ServiceAdapter(Context context, List<ServiceBean> datas) {
        super(context, datas, R.layout.item_service);
        this.context = context;
        loaderImage = new LoaderImage(context);
    }

    @Override
    public void convert(int position, ViewHolder helper, final ServiceBean item) {
        headImage = helper.getView(R.id.head_image);
        mTvName = helper.getView(R.id.tv_name);
        mTvDescription = helper.getView(R.id.tv_description);
        mTvPrize = helper.getView(R.id.tv_prize);
        mTvName.setText(item.getName());
        mTvDescription.setText(item.getDescription());
        mTvPrize.setText("￥" + item.getPrize());
        loaderImage.load(headImage, item.getPicUrl());
        helper.getView(R.id.ll_service).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ServiceDetailActivity.class);
                intent.putExtra("prdId", item.getPrdId());
                context.startActivity(intent);
            }
        });
    }
}
